"""
https://stackoverflow.com/questions/67671132/how-to-get-a-train-or-test-slicing-elegantly-after-splitting
https://codereview.stackexchange.com/questions/261139/get-a-train-or-test-slicing-elegantly-after-splitting
"""
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split

m = 10
x1 = np.arange(m)
x2 = x1 * 2
x3 = x1 * 3
x4 = x1 * 4
x = np.c_[x1, x2, x3, x4]
x = pd.DataFrame(x)
print(x)

offset_orig = range(m)
offset_train, offset_test = train_test_split(offset_orig, train_size=0.7, random_state=666)
print(offset_train)
print(offset_test)
x_train = x.iloc[offset_train]  # later
x_test = x.iloc[offset_test]
print(x_train)
print(x_test)
